#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
struct ListNode
{
	struct ListNode* next;
	int val;
};
typedef struct ListNode ListNode;

bool hasCycle(struct ListNode* head) {
    struct ListNode* fast = head;
    struct ListNode* slow = head;

    while (fast&&fast->next) {
        fast = fast->next->next;
        slow = slow->next;
        if (fast == slow)
            return true;
    }

    return false;
}

int main()
{
	ListNode* node1 = (ListNode*)malloc(sizeof(ListNode));
    ListNode* node2 = (ListNode*)malloc(sizeof(ListNode));
	node1->next = node2;
    node2->next = NULL;
    node1->val = 1;
    node2->val = 2;


    bool ret = hasCycle(node1);
}
1-NU